package com.ly.hotel.util;


import android.content.Context;
import android.content.IntentFilter;
import android.net.ConnectivityManager;

import com.ly.hotel.broadcast.NetworkStateReceiver;

public class NetworkStateChecker{

	// 网络状态广播
	private static NetworkStateReceiver netWorkReceiver = new NetworkStateReceiver();
	private static NetworkStateChecker myreceiver;
	
	private NetworkStateChecker(){}
	
	public static synchronized NetworkStateChecker getInstance() {
		if (myreceiver == null) {
				myreceiver = new NetworkStateChecker();
		}
		return myreceiver;
	}
	
	//停止广播
	public synchronized void stop(Context context)
	{
		try {
			context.unregisterReceiver(netWorkReceiver);
		} catch (Exception e) {
		}
	}
	
	//启动广播
	public synchronized void start(Context context)
	{
		//网络测试状态
		IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
		context.registerReceiver(netWorkReceiver, intentFilter);
	}
	
	
}
